function replaceSubstring(inputString, fromString, toString) {
var temp = inputString;
if (fromString == "") {
return inputString;
}
if (toString.indexOf(fromString) == -1) {
while (temp.indexOf(fromString) != -1) {
var toTheLeft = temp.substring(0, temp.indexOf(fromString));
var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
temp = toTheLeft + toString + toTheRight;
}
} else {
var midStrings = new Array("~", "`", "_", "^", "#");
var midStringLen = 1;
var midString = "";
while (midString == "") {
for (var i=0; i < midStrings.length; i++) {
var tempMidString = "";
for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
if (fromString.indexOf(tempMidString) == -1) {
midString = tempMidString;
i = midStrings.length + 1;
}
}
}
while (temp.indexOf(fromString) != -1) {
var toTheLeft = temp.substring(0, temp.indexOf(fromString));
var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
temp = toTheLeft + midString + toTheRight;
}
while (temp.indexOf(midString) != -1) {
var toTheLeft = temp.substring(0, temp.indexOf(midString));
var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
temp = toTheLeft + toString + toTheRight;
}
}
return temp;
}
function trim(inputString) {
if (typeof inputString != "string") { return inputString; }
var retValue = inputString;
var ch = retValue.substring(0, 1);
while (ch == " ") {
retValue = retValue.substring(1, retValue.length);
ch = retValue.substring(0, 1);
}
ch = retValue.substring(retValue.length-1, retValue.length);
while (ch == " ") {
retValue = retValue.substring(0, retValue.length-1);
ch = retValue.substring(retValue.length-1, retValue.length);
}
while (retValue.indexOf(" ") != -1) {
retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1, retValue.length); // Again, there are two spaces in each of the strings
}
return retValue;
}
//****************************************************
function datediff(date1,date2)
{
var temp1 = new Array();
var temp2 = new Array();
temp1 = date1.split("/")
temp2 = date2.split("/")
//Set the two dates
var millennium =new Date(temp1[2], temp1[0]-1, temp1[1]) //Month is 0-11 in JavaScript
today=new Date(temp2[2], temp2[0]-1, temp2[1])
//Get 1 day in milliseconds
var one_day=1000*60*60*24
//Calculate difference btw the two dates, and convert to days
return (Math.ceil((today.getTime()-millennium.getTime())/(one_day)))
}
//****************************************************
function isArray(obj)
{
return(typeof(obj.length)=="undefined")?false:true;
}
//****************************************************
function SelectRadio(ctrl,num,tmp_value)
{
for (i=0 ; i e ){
if (frmID.elements[e].type == "text" || frmID.elements[e].type == "password" || frmID.elements[e].type == "textarea" || frmID.elements[e].type == "hidden" ){
frmID.elements[e].value = "";
}
else
if (frmID.elements[e].type == "select-one" ){
if (frmID.elements[e].name != "cboPackage" )
/// frmID.elements[e].selectedIndex = 0;
frmID.elements[e].value = 0;
}
else
if (frmID.elements[e].type == "checkbox" ){
frmID.elements[e].checked = false;
}
else
if (frmID.elements[e].type == "radio" )
document.getElementById(frmID.elements[e].name).checked = true;
e = e + 1;
}
}
//************************************************************//
function isLeapYear(Year)
{
if (((Year % 4)==0) && ((Year % 100)!=0) || ((Year % 400)==0)) {
return true;
}
}
//************************************************************//
//*******************************************************************//
/**
* strPad
*
* Pad a string to a certain length with another string
*
* This functions returns the input string padded on the left, the right, or both sides
* to the specified padding length. If the optional argument pad_string is not supplied,
* the output is padded with spaces, otherwise it is padded with characters from pad_string
* up to the limit.
*
* The optional argument pad_type can be STR_PAD_RIGHT, STR_PAD_LEFT, or STR_PAD_BOTH.
* If pad_type is not specified it is assumed to be STR_PAD_RIGHT.
*
* If the value of pad_length is negative or less than the length of the input string,
* no padding takes place.
*
* object string
* return string
*
* examples:
* var input = 'foo';
* input.strPad(9); // returns "foo "
* input.strPad(9, "*+", STR_PAD_LEFT); // returns "*+*+*+foo"
* input.strPad(9, "*", STR_PAD_BOTH); // returns "***foo***"
* input.strPad(9 , "*********"); // returns "foo******"
*/
var STR_PAD_LEFT = 0;
var STR_PAD_RIGHT = 1;
var STR_PAD_BOTH = 2;
String.prototype.strPad = function(pad_length, pad_string, pad_type)
{
/* Helper variables */
var num_pad_chars = pad_length - this.length;/* Number of padding characters */
var result = ''; /* Resulting string */
var pad_str_val = ' ';
var pad_str_len = 0; /* Length of the padding string */
var pad_type_val = pad_type; /* The padding type value */
var i = 0;
var left_pad = 0;
var right_pad = 0;
var error = false;
var error_msg = '';
var output = this;
if (arguments.length < 2 || arguments.length > 4)
{
error = true;
error_msg = "Wrong parameter count.";
}
else if(isNaN(arguments[0]) == true)
{
error = true;
error_msg = "Padding length must be an integer.";
}
/* Setup the padding string values if specified. */
if (arguments.length > 2)
{
if (pad_string.length == 0)
{
error = true;
error_msg = "Padding string cannot be empty.";
}
pad_str_val = pad_string;
pad_str_len = pad_string.length;
if (arguments.length > 3)
{
pad_type_val = pad_type;
if (pad_type_val < STR_PAD_LEFT || pad_type_val > STR_PAD_BOTH)
{
error = true;
error_msg = "Padding type has to be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH."
}
}
}
if(error) throw error_msg;
if(num_pad_chars > 0 && !error)
{
/* We need to figure out the left/right padding lengths. */
switch (pad_type_val)
{
case STR_PAD_RIGHT:
left_pad = 0;
right_pad = num_pad_chars;
break;
case STR_PAD_LEFT:
left_pad = num_pad_chars;
right_pad = 0;
break;
case STR_PAD_BOTH:
left_pad = Math.floor(num_pad_chars / 2);
right_pad = num_pad_chars - left_pad;
break;
}
for(i = 0; i < left_pad; i++)
{
output = pad_str_val.substr(0,num_pad_chars) + output;
}
for(i = 0; i < right_pad; i++)
{
output += pad_str_val.substr(0,num_pad_chars);
}
}
return output;
}
///////////////////////////////////////////////////////
function getDays(month, year) {
// create array to hold number of days in each month
var ar = new Array(12);
ar[0] = 31; // January
ar[1] = (isLeapYear(year)) ? 29 : 28; // February
ar[2] = 31; // March
ar[3] = 30; // April
ar[4] = 31; // May
ar[5] = 30; // June
ar[6] = 31; // July
ar[7] = 31; // August
ar[8] = 30; // September
ar[9] = 31; // October
ar[10] = 30; // November
ar[11] = 31; // December
// return number of days in the specified month (parameter)
return ar[month];
}
//************************************************************//
//---------------selected value for ddl-------------------
//------parameter-------(valueto be selected, object)-----
function SelectDD(cnt,obj)
{
if(cnt != "")
{
for (i = 0 ; i < obj.length ; i++)
{
if (obj.options[i].value == cnt)
{
obj.options[i].selected = true ;
break;
}
}
}
}
//************************************************************//
//************************************************************//
//--------------rights selected------------------
function Sel_option(cnt, ctrl)
{
Form = document.frm_user;
tmp_control = Form[ctrl];
total_chk_box = tmp_control.length;
if(cnt != "")
{
var name;
for (i = 1 ; i <= total_chk_box ; i++)
{
if (cnt == i)
{
var obj_sel=document.getElementById("rights"+i);
obj_sel.checked = true ;
}
}//end for
}
} //end function
//************************************************************//
//********************* ADDED BY HARIS HABIB *****************//
function chk_numeric(val)
{
var re = /^[0-9]*$/;
if (!val.match(re))
return 0;
else
return 1;
}
function chk_url(val)
{
var re = "([http:\/\/]*)www.([-+/w+]+[-+.][-+/w+]+)*([-+.][-+/w+]+)*((//[-+/w+]+)*//[-+/w+]+[-+.][-+/w+]+)*";
if (!val.match(re))
return 0;
else
return 1;
}
function Replace_Sub_String ( inputString, badString, goodString, caseSensitive ) {
fixedReplace = " ";
UI = inputString;
UB = badString;
if ((caseSensitive !=1) && (caseSensitive != true)) {
UI = inputString.toUpperCase();
UB = badString.toUpperCase();
}
badEnd = -1;
badLoc = UI.indexOf(UB);
if (badLoc != -1) {
for (x=1; (badLoc != -1); x++) {
fixedReplace = fixedReplace + inputString.substring((badEnd + 1), badLoc) + goodString
badEnd = badLoc + UB.length - 1;
badLoc = UI.indexOf(UB, (badLoc + 1)); }
fixedReplace = fixedReplace + inputString.substring((badEnd + 1), inputString.length); }
else { fixedReplace = inputString; }
return fixedReplace;
}
function Upper(f){
var str=f.value;
var res=""
str = str.split(" ");
for (i=0; i 900)
{
errormsg = errormsg + "The character limit for Description is 900. \n";
}
}
//----------------------------------------------------------------
//-----------Additional Comments----------------------------------------
if (Form.addcomm.value =="")
{
errormsg = errormsg + "Error: Please Enter Additional Comments. \n";
}
else
{
inputStr = document.frm_brochure.addcomm.value;
strlength= inputStr.length;
if (strlength > 900)
{
errormsg = errormsg + "The character limit for additional comments is 900. \n";
}
}
//----------------------------------------------------------------
//----------------------------------------------------------------
if(Form.terms.checked!=true)
{
errormsg = errormsg + "You cannot Order unless you Agree to the Terms and Conditions. \n";
}
//----------------------------------------------------------------
if (errormsg == "")
{
Form.action = "brochure_order_process.php" ;
Form.submit();
}
else
{
alert ( errormsg );
}
}
//------------------------------------------------
//Validation for web Project
//------------------------------------------------
function ValidateForm_web()
{
var errormsg = "";
Form = document.frm_web;
//------------First Name ----------------------------------
if (!chkEmpty(Form.fname.value))
{errormsg = errormsg + "Error: Please Enter First Name. \n";
}
if (chkEmpty(Form.fname.value))
if(!chkChrOnly(Form.fname.value))
errormsg = errormsg + "Error: Invalid Input For First Name. \n";
//--------------------------------------------------------------
//-----------------Last Name-----------------------------------
if (!chkEmpty(Form.lname.value))
{ errormsg = errormsg + "Error: Please Enter Last Name. \n";
}
if (chkEmpty(Form.lname.value))
if(!chkChrOnly(Form.lname.value))
errormsg = errormsg + "Error: Invalid Input For Last Name. \n";
//---------------------------------------------------------------
//--------------------Company Name-------------------------------
if (!chkEmpty(Form.compname.value))
{ errormsg = errormsg + "Error: Please Enter Company Name. \n";
Form.compname.focus();
}
if (chkEmpty(Form.compname.value))
if(!chkpcName(Form.compname.value))
errormsg = errormsg + "Error: Invalid Input For Company Name. \n";
//---------------------------------------------------------------
//--------------Address------------------------------------------
if (!chkEmpty(Form.address.value))
{ errormsg = errormsg + "Error: Please Enter Address. \n";
}
if (chkEmpty(Form.address.value))
if(!chk_address(Form.address.value))
errormsg = errormsg + "Error: Invalid Input For Address. \n";
//----------------------------------------------------------------
//-----------City----------------------------------------
if (!chkEmpty(Form.city.value))
{ errormsg = errormsg + "Error: Please Enter City. \n";
}
if (chkEmpty(Form.city.value))
if(!chkCityName(Form.city.value))
errormsg = errormsg + "Error: Invalid Input For City. \n";
//-------------------------------------------------------
//-----------State----------------------------------------
//----------------------------------------------------------------
//-----------Zip Code----------------------------------------
if (!chkEmpty(Form.zip.value))
{ errormsg = errormsg + "Error: Please Enter Zip Code. \n";
}
if (chkEmpty(Form.zip.value))
if(!chkZipCode(Form.zip.value))
errormsg = errormsg + "Error: Invalid Input For Zip Code. \n";
//----------------------------------------------------------------
//-----------Country----------------------------------------
if (!chkEmpty(Form.country.value))
{ errormsg = errormsg + "Error: Please Enter Country. \n";
}
//----------------------------------------------------------------
//-------------------Phone----------------------------------------
if (!chkEmpty(Form.phone.value))
{ errormsg = errormsg + "Error: Please Enter Phone Number. \n";
}
if (chkEmpty(Form.phone.value))
if(!chkPhone(Form.phone.value))
errormsg = errormsg + "Error: Invalid Phone Number. \n";
//----------------------------------------------------------------
//-----------Email----------------------------------------
if (!chkEmpty(Form.email.value))
{ errormsg = errormsg + "Error: Please Enter Email Address. \n";
}
if (chkEmpty(Form.email.value))
if(!chkEmail(Form.email.value))
errormsg = errormsg + "Error: Invalid Email Address . \n";
//----------------------------------------------------------------
//-----------Alternate Email----------------------------------------
if (chkEmpty(Form.aemail.value))
if(!chkEmail(Form.aemail.value))
errormsg = errormsg + "Error: Invalid Alternate Email Address . \n";
//----------------------------------------------------------------
//-----------Description----------------------------------------
if (Form.desc.value == "")
errormsg = errormsg + "Error: Please Enter Description. \n";
//----------------------------------------------------------------
//-----------competitors ----------------------------------------
if (Form.business.value =="")
{
errormsg = errormsg + "Error: Please Enter Type of Business. \n";
}
else
{
inputStr = document.frm_web.business.value;
strlength= inputStr.length;
if (strlength > 700)
{
errormsg = errormsg + "Error: The character limit for Business Type is 700. \n";
}
}
//----------------------------------------------------------------
if (Form.mood.value !="")
{
inputStr = document.frm_web.mood.value;
strlength= inputStr.length;
if (strlength > 700)
{
errormsg = errormsg + "Error: The character limit is 700. \n";
}
}
//----------------------------------------------------------------
if(Form.terms.checked!=true)
{
errormsg = errormsg + "You cannot Order unless you Agree to the Terms and Conditions. \n";
}
//----------------------------------------------------------------
if (errormsg == "")
{
Form.action = "web_order_process.php" ;
Form.submit();
}
else
{
alert ( errormsg );
}
}
Logo Design Guru Wins Two
American Graphic Design Awards ...
More
"We feel the quality of the portfolios speak
more than the price but obviously as a business we are looking for
the lowest price for the best product."
Character Comforts
Paul Pavlou, Essex