var defValues = {
"fName":"First Name *","fLastName":"Last Name","fEmail":"Email *","fPhone":"Phone","feedback":"Message *" };
jQuery.getScript('templates/iio_m/js/uploadify/jquery.uploadify.v2.1.4.min.js',function(){
jQuery.getScript('templates/iio_m/js/uploadify/swfobject.js',function(){
uploadButton();
});
});
function uploadButton(){
jQuery('#custom_file_upload').uploadify({
'uploader' : 'templates/iio_m/js/uploadify/uploadify.swf',
'script' : 'templates/iio_m/js/uploadify/uploadify.php',
'cancelImg' : 'templates/iio_m/js/uploadify/cancel.png',
'folder' : 'images/feedback/tmp',
'multi' : true,
'auto' : false,
'fileExt' : '*.jpg;*.gif;*.png',
'fileDesc' : 'Image Files (.JPG, .GIF, .PNG)',
'queueSizeLimit' : 3,
'simUploadLimit' : 3,
'sizeLimit' : 204800,
});
}
function pageJS()
{
jQuery('#option-buttons').buttonset();
jQuery('#feedback-form input[type="text"],#feedback-form textarea').unbind('focus').focus(function(){
jQuery(this).addClass('ui-state-active');
});
jQuery('#feedback-form input[type="text"],#feedback-form textarea').unbind('keydown').keydown(function(){
jQuery(this).addClass('ui-state-active');
var defValue = eval('defValues.'+jQuery(this).attr('name'));
if(jQuery(this).val() == defValue) {
jQuery(this).val('');
}
});
jQuery('#feedback-form input[type="text"],#feedback-form textarea').unbind('blur').blur(function(){
jQuery(this).removeClass('ui-state-active');
var defValue = eval('defValues.'+jQuery(this).attr('name'));
if(jQuery(this).val() == '') {
jQuery(this).val(defValue);
}
});
jQuery('#cancel').unbind('click').click(function(){
jQuery("#feedback-form").animate({opacity:0.4});
jQuery.get(jQuery("#feedback-form").attr('action') , function(data){
jQuery("#feedback-form").animate({opacity:1});
jQuery("#feedback-form").html(jQuery(data).find('#feedback-form').html());
pageJS();
});
return false;
});
uploadButton();
}
function formCheck(){
var errors = new Array();
jQuery('.imp').each(function(){
var defValue = eval('defValues.'+jQuery(this).attr('name'));
if(jQuery(this).val() == '' || jQuery(this).val() == defValue) {
errors.push(defValue);
}
});
if(errors.length != 0){
return false;
}
return true;
}
jQuery('#feedback-form').unbind('submit').submit(function(event){
event.preventDefault();
jQuery(this).animate({opacity:0.4});
jQuery.post(this.action , jQuery(this).serialize() , function(data){
if(formCheck()){
var email = jQuery('#feedback-form input[name="fEmail"]').val();
jQuery('#custom_file_upload').uploadifySettings('folder','images/feedback/'+email);
jQuery('#custom_file_upload').uploadifyUpload();
}
jQuery("#feedback-form").animate({opacity:1});
jQuery("#feedback-form").html(jQuery(data).find('#feedback-form').html());
pageJS();
});
return false;
});
pageJS();